
/**
 * 包声明  第三种方式
 */
package com.zhanghe.study.study_scala.oop { // 包com.zhanghe.study.study_scala，块内可以声明package，class，object

  package object service {
    var adType: String = "2"

    def sayHi(): Unit = {
      println("service sayHi")
    }
  }

  package model {

    // 子包，com.zhanghe.study.study_scala.oop.model
    class Dog {
      // 包访问权限 表示service包可以使用
      private[oop] var name: String = _
    }

  }

  package service {

    import com.zhanghe.study.study_scala.oop.model.Dog // 子包，com.zhanghe.study.study_scala.oop.service

    object DogServiceImp {
      def main(args: Array[String]): Unit = {
        var cat: Cat = Cat()
        sayHi()

        var dog:Dog = new Dog
        println(dog.name)

      }
    }

  }

  package object people{
    // 使用包对象来声明常量
    val defaultName = "人"
  }

  package people{
    class Person {
      // 直接从包对象中取常量
      var name = defaultName
    }
  }

}

package com.zhanghe.study.study_scala.oop { // 包com.zhanghe.study.study_scala.oop，块内可以声明package，class，object

  class Cow {
    var age: Int = _
  }

}
